package com.xy.biz.rs.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.rs.domain.bo.ManufactureRecordBO;
import com.xy.biz.rs.domain.po.ManufactureRecordPO;
import com.xy.biz.rs.domain.query.ManufactureRecordQuery;
import com.xy.biz.rs.domain.resp.GetManufactureRecordResponse;
import com.xy.biz.rs.domain.req.SaveManufactureRecordRequest;
import com.xy.biz.rs.domain.req.ListManufactureRecordRequest;

/**
 *
 *
 * @author wwj
 * @date 2021-4-16
 */
public class ManufactureRecordConverter {

	public static ManufactureRecordPO toPO(ManufactureRecordBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureRecordPO(), true);
	}

	public static List<ManufactureRecordPO> toPO(Collection<ManufactureRecordBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureRecordPO(), true);
	}

	public static ManufactureRecordBO fromPO(ManufactureRecordPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureRecordBO());
	}

	public static List<ManufactureRecordBO> fromPO(Collection<ManufactureRecordPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureRecordBO());
	}

	public static ManufactureRecordBO toBO(SaveManufactureRecordRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureRecordBO(), true);
	}

	public static List<ManufactureRecordBO> toBO(Collection<SaveManufactureRecordRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureRecordBO(), true);
	}

	public static GetManufactureRecordResponse toResponse(ManufactureRecordBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetManufactureRecordResponse());
	}

	public static List<GetManufactureRecordResponse> toResponse(Collection<ManufactureRecordBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetManufactureRecordResponse());
	}

	public static ManufactureRecordQuery toQuery(ListManufactureRecordRequest source) {
		if(null == source) {
			return null;
		}
		ManufactureRecordQuery target = new ManufactureRecordQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
